libnss-rs
Rust bindings for creating libnss modules.
Currently supports the following databases:
- passwd
- shadow
- group
- hosts
Getting started
- Create a new library
- Change library type to
cdylib
in yourCargo.toml
name = "nss_example"
crate-type = [ "cdylib" ]
*** NOTE *** The name of the crate itself is not important, however the library itself must follow the nss_xxx
pattern.
- Add
libnss
to yourCargo.toml
libc = "0.2.0"
lazy_static = "1.3.0"
paste = "0.1"
libnss = "0.1.0"
- Add the following to your
src/main.rs
extern crate libc;
extern crate lazy_static;
extern crate libnss;
- Implement a
passwd
database
use ;
;
libnss_passwd_hooks!;
It is important that the first param of libnss_passwd_hooks
is the name of your final library libnss_example.so.2
- Install the library
- Enable your nss module in
/etc/nsswitch.conf
eg:
passwd: example files systemd
The name in here must follow the final library name libnss_example.so.2
- Look at the examples for more information